#include <stdio.h>
#include "malloc.h"
typedef char dataType;
typedef struct TreeNode{
    dataType data;
    struct TreeNode *Lchild;
    struct TreeNode *Rchild;
}TreeNode,*Tree;

TreeNode* createNode(dataType n){
    TreeNode * newNode=(TreeNode *)malloc(sizeof(TreeNode));
    if(newNode==NULL){
        printf("分配内存失败");
        return NULL;
    }
    newNode->data=n;
    newNode->Lchild=NULL;
    newNode->Rchild=NULL;
    return newNode;
}
//先序
void preOrder(Tree T){
    if(T!=NULL){
        printf("%c ",T->data);
        preOrder(T->Lchild);
        preOrder(T->Rchild);
    }
}
//后序
void postOrder(Tree T){
    if(T != NULL){
        postOrder(T->Lchild);
        postOrder(T->Rchild);
        printf("%c ",T->data);
    }
}
int main() {
    TreeNode *node1 = createNode('A');
    TreeNode *node2 = createNode('B');
    TreeNode *node3 = createNode('C');
    TreeNode *node4 = createNode('D');
    TreeNode *node5 = createNode('E');

    node1->Lchild=node2;
    node1->Rchild=node3;
    node2->Lchild=node4;
    node2->Rchild=node5;

    printf("================先序");
    preOrder(node1);
}